/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.yxw.live_vod_boot.enums;

import com.yxw.yxnet_cd_center.common.constant.CommonConstant;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * mqtt 主题枚举
 * @author lx
 * 2023.10.7
 */
public enum MqttTopicEnum {

    /**
     * 前端订阅主题
     */
    SYSTEM_NOTICE_TOPIC("SYSTEM_NOTICE_TOPIC_",CommonConstant.MQTT_CLIENT_TOPIC,"视频上传审核消息主题前缀"),

    /**
     * 用户登录强制下线主题
     * @param topic
     * @param topicType
     * @param describe
     */
    SYSTEM_OFFLINE_TOPIC("LIVE_SYS_OFFLINE_",CommonConstant.MQTT_CLIENT_TOPIC,"用户登录强制下线主题"),


    /**
     *会话主题
     */
    TALK_SESSION_TOPIC("TALK_SESSION_TOPIC_",CommonConstant.MQTT_CLIENT_TOPIC,"会话主题"),

    /**
     * 直播评论主题
     */
    LIVE_COMMENT_TOPIC("LIVE_COMMENT_TOPIC_",CommonConstant.MQTT_CLIENT_TOPIC,"直播评论主题"),

    /**
     *订单超时主题
     */
    ORDER_TIMEOUT_TOPIC("ORDER_TIMEOUT_TOPIC_",CommonConstant.MQTT_CLIENT_TOPIC,"订单超时主题"),

    /**
     * 点播视频获取火山引擎播放地址-生产者
     */
    VOD_PLAYURL_DELAYED_PRODUCT("$delayed/30/VOD_PLAYURL_DELAYED_TOPIC/","","点播视频获取火山引擎播放地址-生产者"),

    /**
     * 点播视频获取火山引擎播放地址-消费者
     */
    VOD_PLAYURL_DELAYED_CONSUMER("VOD_PLAYURL_DELAYED_TOPIC/",CommonConstant.MQTT_SERVER_TOPIC,"点播视频获取火山引擎播放地址-消费者");

    MqttTopicEnum(String topic, String topicType, String describe) {
        this.topic = topic;
        this.topicType = topicType;
        this.describe = describe;
    }

    /**
     * 主题前缀
     */
    @Getter
    private String topic;

    /**
     * 主题类型
     * server:服务端订阅主题
     *client:客户端订阅主题
     */
    @Getter
    private String topicType;
    /**
     * 主题前缀描述
     */
    @Getter
    private String describe;

    /**
     * 初始化延迟消息队列
     * @return
     */
    public static List<String> getSeverTopicList(){
        ArrayList<String> topicList = new ArrayList<>();
        for (MqttTopicEnum topicEnum : values()) {
            if (topicEnum.getTopicType().equals(CommonConstant.MQTT_SERVER_TOPIC)) {
                topicList.add("$share/live_vod/".concat(topicEnum.getTopic().concat("+")));
            }
        }
        return topicList;
    }

    /**
     * 获取客户端订阅主题列表
     */
    public static List<String> getClientTopicList(){
        ArrayList<String> topicList = new ArrayList<>();
        for (MqttTopicEnum topicEnum : values()) {
            if (topicEnum.getTopic().equals(CommonConstant.MQTT_CLIENT_TOPIC)) {
                topicList.add(topicEnum.getTopic());
            }
        }
        return topicList;
    }
}
